package com.water.devtool;

import java.util.HashMap;
import java.util.Map;

import com.water.devtool.constant.DbType;

public class TableUtilFactory {

	private static Map<DbType, ITableUtil> utils = new HashMap<DbType, ITableUtil>();

	public static ITableUtil create(DbType type) {
		ITableUtil t = utils.get(type);
		if (t != null) {
			return t;
		}
		switch (type) {
		case ORACLE:
			t = new TableUtil();
			break;
		case MYSQL:
			t = new TableUtilForMysql();
			break;
		case POSTGRESQL:
			t = new TableUtilForPostgreSQL();
			break;
		default:
			t = new TableUtil();
			break;
		}
		utils.put(type, t);
		return t;
	}

	public static ITableUtil create() {
		return create(DbType.ORACLE);
	}

}
